package middle;

public class Solution_45 {

    public int jump(int[] nums) {
        int[] array = new int[nums.length];
        for (int i = 1; i < nums.length; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < i; j++) {
                if (j + nums[j] >= i && array[j] < min) {
                    min = array[j];
                }
            }
            array[i] = min + 1;
        }
        return array[array.length - 1];
    }

    public static void main(String[] args) {
        Solution_45 model = new Solution_45();
        System.out.println(model.jump(new int[]{2, 3, 1, 1, 4}));
        System.out.println(model.jump(new int[]{2, 3, 1, 1, 4}));
    }
}
